package com.sskj.boom.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.sskj.boom.R;
import com.sskj.boom.R2;
import com.sskj.boom.bean.StockBloomBean;
import com.sskj.boom.boomview.widget.BoomView;
import com.sskj.boom.presenter.BoomViewPresenter;
import com.sskj.common.rxbus2.RxBus;
import com.sskj.common.rxbus2.Subscribe;
import com.sskj.common.rxbus2.ThreadMode;
import com.sskj.lib.RConfig;
import com.sskj.lib.base.BaseFragment;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * @author Hey
 * Create at  2019/06/27
 */
@Route(path = RConfig.BOOM_FRAGMENT_BOOM)
public class BoomFragment extends BaseFragment<BoomViewPresenter> {


    @BindView(R2.id.boomView)
    BoomView boomView;
    private boolean isFall;

    @Override
    public int getLayoutId() {
        return R.layout.boom_fragment_boom;
    }

    @Override
    public BoomViewPresenter getPresenter() {
        return new BoomViewPresenter();
    }


    @Subscribe(threadMode = ThreadMode.MAIN)
    public void changeFive(StockBloomBean stockBloomBean) {
        if (stockBloomBean != null) {
            switch (stockBloomBean.getStatus()) {
                case 1:
                    boomView.gamePreparing((int) (Double.valueOf(stockBloomBean.getData().get(0).getPrepare().getSt())
                            - Double.valueOf(stockBloomBean.getData().get(0).getPrepare().getPt())));
                    break;
                case 2:
                    boomView.gameStart();
                    break;
                case 3:
                    boomView.gameOver((float) stockBloomBean.getData().get(0).getCrash().getBoomValue());
                    break;
            }
        }
    }


    @Override
    public void initView() {
        RxBus.getDefault().register(this);

    }


    @Override
    public void initData() {

    }

}
